home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 January / macformat-033.iso / mac / Shareware City / Developers / ABox.v1.8 / CPlus Files / ABStr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-23  |  4.6 KB  |  200 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABStr.c
  15.  
  16. NAME
  17.     ABStr.c, part of the ABox project source code,
  18.     responsible for handling the AboutBox Str class stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                netromancr@aol.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <netromancr@aol.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     9 June 94    -    ty    -    Initial Version Created
  36.     20-july-94    -    ty    -    initial version released
  37.     28-july-94    -    ty    -    1.0.6--additions to support settable speech mgr usage
  38.                                     via the ABox Get/SetProperty methods
  39.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  40.                             release and the associated Universal Headers from Apple:
  41.                             most methods that returned references now have "Ref" at
  42.                             the end of their methods names to prevent possible collisions
  43.                             with datatypes and classes of the same name (older versions
  44.                             of the compiler didn't have a problem with this).
  45.  
  46. */
  47.  
  48. /*===========================================================================*/
  49.  
  50. /*======= Segmentation directives ========*/
  51.  
  52. #ifdef USE_MANUAL_SEGMENTATION
  53. #pragma segment ty
  54. #endif
  55.  
  56. /*============ Header files ==============*/
  57.     
  58. #include     "ABStr.h"
  59. #include    "ABox.h"
  60.  
  61. /*=============== Globals ================*/
  62.  
  63. /*================ CODE ==================*/
  64.  
  65.  
  66. /*=============================== ABStr::ABStr ================================*/
  67. ABStr::ABStr(void)
  68. {
  69.     mResType = kABStringResource;
  70. } // end ABStr
  71.  
  72.  
  73.  
  74. /*=============================== ABStr::~ABStr ================================*/
  75. ABStr::~ABStr(void)
  76. {
  77. } // end ~ABStr
  78.  
  79.  
  80.  
  81.  
  82.  
  83. /*=============================== ABStr::Draw ================================*/
  84. OSErr    ABStr::Draw(WindowPtr window)
  85. {
  86.     OSErr        error = noErr;
  87.     Rect        box;
  88.     
  89.     //    begin here...
  90.     
  91.     error = ABObject::Draw(window);
  92.     if (error == noErr)
  93.     {
  94.             
  95.         //    get the display area...
  96.         //
  97.         box = this->ObjectRect();
  98.         
  99.         error = this->InitializeResource();
  100.     
  101.         if (this->DoesntHaveResourceHandleRef())
  102.             return noErr;
  103.     
  104.         ::HLockHi (this->ResourceHandleRef());
  105.         if (**(this->ResourceHandleRef()) > 0) 
  106.         {
  107.             error = this->DrawTextBox ((unsigned char *)&((*(this->ResourceHandleRef()))[1]),    //    unsigned char *c
  108.                                 **(this->ResourceHandleRef()),                    //    unsigned long textSize
  109.                                 &box,                            //    Rect *displayWrapRect
  110.                                 teJustCenter,                     //    short alignmentConstants
  111.                                 0,                                //    lineHeightCode (0 = default)
  112.                                 NULL,                            //    short *endY baseline
  113.                                 NULL);                            //    short *lineHeight
  114.         } // end if block
  115.         ::HUnlock (this->ResourceHandleRef());
  116.     
  117.     }
  118.     
  119.     return error;
  120.     
  121. } // end Draw
  122.  
  123.  
  124.  
  125.  
  126. /*=============================== ABStr::Event ================================*/
  127. Boolean    ABStr::Event(EventRecord *event)
  128. {
  129.     Boolean        handled = false;
  130.     Point        where;
  131.     OSErr        error = noErr;
  132.     
  133.     //    begin here...
  134.     //
  135.     if (!event)
  136.         return handled;
  137.     
  138.     switch (event->what) 
  139.     {
  140.         case    mouseDown:    
  141.             //    1.0.6 ty--check to see if we're allowed to use the Text-To-Speech Mgr
  142.             //
  143.             ABox *theABox = (ABox *)::GetWRefCon (this->OurWindowRef());
  144.             Boolean    useSpeech = false;
  145.             
  146.             if (theABox)
  147.                 error = theABox->GetProperty(kABoxUseSpeechMgr, &useSpeech, NULL);
  148.             
  149.             where = event->where;
  150.             ::GlobalToLocal(&where);
  151.             if (::PtInRect (where, &(this->ObjectRect())) && 
  152.                 (::FrontWindow() == this->OurWindowRef()) && 
  153.                 ABUEnvSpeechSynth::IsPresent() && 
  154.                 useSpeech) 
  155.             {
  156.                 //    Stop speaking first
  157.                 error = End();
  158.                 
  159.                 //    speak the string!
  160.                 if (this->HasResourceHandleRef())
  161.                 {
  162.                     ::HLock(this->ResourceHandleRef());
  163.                     error = ::SpeakString ((StringPtr)*(this->ResourceHandleRef()));
  164.                     ::HUnlock(this->ResourceHandleRef());
  165.                     if (!error)
  166.                         handled = true;
  167.                 } // end if block
  168.             } // end if block
  169.             break;
  170.         default:
  171.             break;
  172.     } // end switch block
  173.     
  174.     return handled;
  175. } // end Event
  176.  
  177.  
  178.  
  179. /*=============================== ABStr::Stop ================================*/
  180. OSErr    ABStr::Stop(void)
  181. {
  182.     OSErr    error = noErr;
  183.     
  184.     //    begin here...
  185.     //
  186.     error = this->End();
  187.     error = ABResource::Stop();
  188.     return error;
  189.     
  190. } // end Stop
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198. //    end of file
  199.  
  200.